Skip to main content
Access via:io.prefs

App Preferences API.

11 Methods

clear()⚓︎

() => Promise<void>

Removes the user preferences for the current app.

Returns

Promise that resolves when the user preferences for the current app have been removed.

clearAll()⚓︎

() => Promise<void>

Removes all preferences stored for the current user.

Returns

Promise that resolves when all preferences stored for the current user have been removed.

clearFor()⚓︎

(app: string) => Promise<void>

Removes the user preferences for a specified app.

Parameters (1)

Name Type Required Description
app⚓︎ string

Name of the app whose user preferences to remove.

Returns

Promise that resolves when the user preferences for a specified app have been removed.

get()⚓︎

(app?: string) => Promise<AppPreferences>

Retrieves the user preferences for the current app.

Parameters (1)

Name Type Required Description
app⚓︎ string x

Name of the app for which to retrieve the user preferences.

Returns

Promise that resolves with the user preferences for the current app.

getAll()⚓︎

() => Promise<{ all: AppPreferences[] }>

Retrieves all preferences stored for the current user.

Returns

Promise that resolves with all preferences stored for the current user.

set()⚓︎

(data: any, options?: { app: string }) => Promise<void>

Replaces the user preferences for the current app. All existing properties will be removed and replaced with the ones supplied in the data object.

Parameters (2)

Name Type Required Description
data⚓︎ any

Data to replace the existing user preferences.

options⚓︎ { app: string } x

Object with an app property that accepts an app name as a value. Can be used to target a specific app whose user preferences to replace.

Returns

Promise that resolves when the user preferences for the current app have been replaced.

setFor()⚓︎

(app: string, data: any) => Promise<void>

Replaces the user preferences of a specified app. All existing properties will be removed and replaced with the ones supplied in the data object.

Parameters (2)

Name Type Required Description
app⚓︎ string

Name of the app whose user preferences to replace.

data⚓︎ any

Data to replace the existing user preferences.

Returns

Promise that resolves when the user preferences of a specified app have been replaced.

subscribe()⚓︎

(callback: (prefs: AppPreferences) => void) => UnsubscribeFunction

Subscribes for changes to the user preferences of the current app.

Parameters (1)

Name Type Required Description
callback⚓︎ (prefs: AppPreferences) => void

Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.

Returns

Unsubscribe function.

subscribeFor()⚓︎

(app: string, callback: (prefs: AppPreferences) => void) => UnsubscribeFunction

Subscribes for changes to the user preferences of a specified app.

Parameters (2)

Name Type Required Description
app⚓︎ string

Name of the app to which to subscribe.

callback⚓︎ (prefs: AppPreferences) => void

Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.

Returns

Unsubscribe function.

update()⚓︎

(data: any, options?: { app: string }) => Promise<void>

Updates the preferences for the current app. The properties specified in the data object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.

Parameters (2)

Name Type Required Description
data⚓︎ any

Data to be merged with the existing user preferences.

options⚓︎ { app: string } x

Object with an app property that accepts an app name as a value. Can be used to target a specific app whose user preferences to update.

Returns

Promise that resolves when the preferences for the current app have been updated.

updateFor()⚓︎

(app: string, data: any) => Promise<void>

Updates the preferences for a specified app. The properties specified in the data object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.

Parameters (2)

Name Type Required Description
app⚓︎ string

Name of the app whose user preferences to update.

data⚓︎ any

Data to be merged with the existing user preferences.

Returns

Promise that resolves when the preferences for a specified app have been updated.